package com.cskaoyan.crud;

import com.cskaoyan.utils.JDBCUtils2;
import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/07/25 17:44
 *
 * @author ciggar
 */
public class DeleteDemo {

    public static void main(String[] args) throws SQLException {


        // 注册驱动
        DriverManager.registerDriver(new Driver());

        // 建立连接
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/43th?useSSL=false&characterEncoding=utf8",
                "root",
                "123456"
        );


        // 获取statement对象
        Statement statement = connection.createStatement();


        // 执行SQL语句
        int affectedRows = statement.executeUpdate("delete from city where id in (4001,5001)");

        System.out.println("affectedRows:" + affectedRows);


        // 关闭资源
        JDBCUtils2.closeResource(statement,connection,null);


    }
}
